package com.example.baselibrary.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.alibaba.android.arouter.launcher.ARouter;
import com.example.baselibrary.iview.BaseView;
import com.example.baselibrary.presenter.BasePresenter;
import com.example.baselibrary.utils.ToastUtil;
import com.example.baselibrary.widgets.ProgressLoading;

/**
 * Activity基类，业务相关 by zqq on 2018/6/11.
 */

public abstract class BaseMvpActivity<T extends BasePresenter> extends BaseActivity implements BaseView {

    public T mPresenter;
    private ProgressLoading mLoadingDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //初始化加载框
        mLoadingDialog = ProgressLoading.create(this);
        //ARouter注册
        ARouter.getInstance().inject(this);
    }


    //显示加载框，默认实现
    @Override
    public void showLoading() {
        mLoadingDialog.showLoading();
    }

    //隐藏加载框，默认实现
    @Override
    public void hideLoading() {
        mLoadingDialog.hideLoading();
    }

    //错误信息提示，默认实现
    @Override
    public void onError(String text) {
        ToastUtil.ToastMsg(this, text);
    }

}
